public class Main {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = new int[]{2,3,1,2,4,3};
        System.out.println(solution.minSubArrayLen(7, nums));
    }
}
class Solution {
    public int minSubArrayLen(int target, int[] nums) {
        int left = 0;
        int right = 0;
        int n = nums.length;
        int sum = 0;
        int ret = Integer.MAX_VALUE;
        while (right<n) {
            sum += nums[right];
            while (sum>=target) {
                ret = Math.min(ret,right-left+1);
                sum -= nums[left];
                left++;
            }
            right++;
        }
        return ret==Integer.MAX_VALUE ? 0 : ret ;
    }
}